package com.gupaoedu.vip;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.lang.reflect.Proxy;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {

        //我要调api接口的方法，又不能new，那只能动态生成代理
//        IHelloService iHelloService =
        /*RpcProxyClient rpcProxyClient = new RpcProxyClient();
        IHelloService iHelloService = rpcProxyClient.clientProxy(IHelloService.class,"127.0.0.1",8080);
        String result = iHelloService.sayHello("tom");
        System.out.println(result);*/


        ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
        RpcProxyClient rpcProxyClient = context.getBean(RpcProxyClient.class);


        IHelloService iHelloService = rpcProxyClient.clientProxy(IHelloService.class,"127.0.0.1",8080);
        String result = iHelloService.sayHello("tom");
        System.out.println(result);


    }
}
